syn keyword nqcConstant EVENT_TYPE_PRESSED EVENT_TYPE_RELEASED
syn keyword nqcConstant EVENT_TYPE_PULSE EVENT_TYPE_EDGE
syn keyword nqcConstant EVENT_TYPE_FAST_CHANGE EVENT_TYPE_LOW
syn keyword nqcConstant EVENT_TYPE_NORMAL EVENT_TYPE_HIGH
syn keyword nqcConstant EVENT_TYPE_CLICK EVENT_TYPE_DOUBLECLICK
syn keyword nqcConstant EVENT_TYPE_MESSAGE
" Scout Events
syn keyword nqcConstant EVENT_1_PRESSED EVENT_1_RELEASED
syn keyword nqcConstant EVENT_2_PRESSED EVENT_2_RELEASED
syn keyword nqcConstant EVENT_LIGHT_HIGH EVENT_LIGHT_NORMAL
syn keyword nqcConstant EVENT_LIGHT_LOW EVENT_LIGHT_CLICK
syn keyword nqcConstant EVENT_LIGHT_DOUBLECLICK EVENT_COUNTER_0
syn keyword nqcConstant EVENT_COUNTER_1 EVENT_TIMER_0 EVENT_TIMER_1
syn keyword nqcConstant EVENT_TIMER_2 EVENT_MESSAGE
" Functions - RCX2, Scout
syn keyword nqcFunction ActiveEvents Event
" Functions - RCX2
syn keyword nqcFunction CurrentEvents
syn keyword nqcFunction SetEvent ClearEvent ClearAllEvents EventState
syn keyword nqcFunction CalibrateEvent SetUpperLimit UpperLimit
syn keyword nqcFunction SetLowerLimit LowerLimit SetHysteresis
syn keyword nqcFunction Hysteresis
syn keyword nqcFunction SetClickTime ClickTime SetClickCounter
syn keyword nqcFunction ClickCounter
" Functions - Scout
syn keyword nqcFunction SetSensorClickTime SetCounterLimit
syn keyword nqcFunction SetTimerLimit
" Data Logging ---------------------------------------
" Functions - RCX
syn keyword nqcFunction CreateDatalog AddToDatalog
syn keyword nqcFunction UploadDatalog
" General Features -----------------------------------
" Functions - All
syn keyword nqcFunction Wait StopAllTasks Random
syn keyword nqcFunction SetSleepTime SleepNow
" Functions - RCX
syn keyword nqcFunction Program Watch SetWatch
" Functions - RCX2
syn keyword nqcFunction SetRandomSeed SelectProgram
syn keyword nqcFunction BatteryLevel FirmwareVersion
" Functions - Scout
" Parameters for SetLight()
syn keyword nqcConstant LIGHT_ON LIGHT_OFF
syn keyword nqcFunction SetScoutRules ScoutRules SetScoutMode
syn keyword nqcFunction SetEventFeedback EventFeedback SetLight
" additional CyberMaster defines
syn keyword nqcConstant OUT_L OUT_R OUT_X
syn keyword nqcConstant SENSOR_L SENSOR_M SENSOR_R
" Functions - CyberMaster
syn keyword nqcFunction Drive OnWait OnWaitDifferent
syn keyword nqcFunction ClearTachoCounter TachoCount TachoSpeed
syn keyword nqcFunction ExternalMotorRunning AGC
" nqcCommentGroup allows adding matches for special things in comments
syn keyword nqcTodo contained TODO FIXME XXX
syn cluster nqcCommentGroup contains=nqcTodo
"when wanted, highlight trailing white space
if exists("nqc_space_errors")
if !exists("nqc_no_trail_space_error")
syn match nqcSpaceError display excludenl "\s\+$"
endif
if !exists("nqc_no_tab_space_error")
syn match nqcSpaceError display " \+\t"me=e-1
endif
endif
"catch errors caused by wrong parenthesis and brackets
syn cluster nqcParenGroup contains=nqcParenError,nqcIncluded,nqcCommentSkip,@nqcCommentGroup,nqcCommentStartError,nqcCommentSkip,nqcCppOut,nqcCppOut2,nqcCppSkip,nqcNumber,nqcFloat,nqcNumbers
if exists("nqc_no_bracket_error")
syn region nqcParen transparent start='(' end=')' contains=ALLBUT,@nqcParenGroup,nqcCppParen
" nqcCppParen: same as nqcParen but ends at end-of-line; used in nqcDefine
syn region nqcCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@nqcParenGroup,nqcParen
syn match nqcParenError display ")"
syn match nqcErrInParen display contained "[{}]"
else
syn region nqcParen transparent start='(' end=')' contains=ALLBUT,@nqcParenGroup,nqcCppParen,nqcErrInBracket,nqcCppBracket
" nqcCppParen: same as nqcParen but ends at end-of-line; used in nqcDefine
syn region nqcCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@nqcParenGroup,nqcErrInBracket,nqcParen,nqcBracket
syn match nqcParenError display "[\])]"
syn match nqcErrInParen display contained "[\]{}]"
syn region nqcBracket transparent start='\[' end=']' contains=ALLBUT,@nqcParenGroup,nqcErrInParen,nqcCppParen,nqcCppBracket
" nqcCppBracket: same as nqcParen but ends at end-of-line; used in nqcDefine
syn region nqcCppBracket transparent start='\[' skip='\\$' excludenl end=']' end='$' contained contains=ALLBUT,@nqcParenGroup,nqcErrInParen,nqcParen,nqcBracket
syn match nqcErrInBracket display contained "[);{}]"
endif
"integer number, or floating point number without a dot and with "f".
syn case ignore
syn match nqcNumbers display transparent "\<\d\|\.\d" contains=nqcNumber,nqcFloat
" Same, but without octal error (for comments)
syn match nqcNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
"hex number
syn match nqcNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
" Flag the first zero of an octal number as something special
syn match nqcFloat display contained "\d\+f"
"floating point number, with dot, optional exponent
syn match nqcFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
"floating point number, starting with a dot, optional exponent
syn match nqcFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match nqcFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
" flag an octal number with wrong digits
syn case match
syn region nqcCommentL start="//" skip="\\$" end="$" keepend contains=@nqcCommentGroup,nqcSpaceError
syn region nqcComment matchgroup=nqcCommentStart start="/\*" matchgroup=NONE end="\*/" contains=@nqcCommentGroup,nqcCommentStartError,nqcSpaceError
" keep a // comment separately, it terminates a preproc. conditional
syntax match nqcCommentError display "\*/"
syntax match nqcCommentStartError display "/\*" contained
syn region nqcPreCondit start="^\s*#\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=nqcComment,nqcCharacter,nqcCppParen,nqcParenError,nqcNumbers,nqcCommentError,nqcSpaceError
syn match nqcPreCondit display "^\s*#\s*\(else\|endif\)\>"
if !exists("nqc_no_if0")
syn region nqcCppOut start="^\s*#\s*if\s\+0\>" end=".\|$" contains=nqcCppOut2
syn region nqcCppOut2 contained start="0" end="^\s*#\s*\(endif\>\|else\>\|elif\>\)" contains=nqcSpaceError,nqcCppSkip
syn region nqcCppSkip contained start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*#\s*endif\>" contains=nqcSpaceError,nqcCppSkip
endif
syn region nqcIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match nqcInclude display "^\s*#\s*include\>\s*["]" contains=nqcIncluded
"syn match nqcLineSkip "\\$"
syn cluster nqcPreProcGroup contains=nqcPreCondit,nqcIncluded,nqcInclude,nqcDefine,nqcErrInParen,nqcErrInBracket,nqcCppOut,nqcCppOut2,nqcCppSkip,nqcNumber,nqcFloat,nqcNumbers,nqcCommentSkip,@nqcCommentGroup,nqcCommentStartError,nqcParen,nqcBracket
syn region nqcDefine start="^\s*#\s*\(define\|undef\)\>" skip="\\$" end="$" contains=ALLBUT,@nqcPreProcGroup
syn region nqcPreProc start="^\s*#\s*\(pragma\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@nqcPreProcGroup
if !exists("nqc_minlines")
if !exists("nqc_no_if0")
let nqc_minlines = 50 " #if 0 constructs can be long